#ifndef _SYS_STR_BUF_H_
#define _SYS_STR_BUF_H_

#include "FanObj.h"
#include "SysTypes.h"

#define STR_BUF_VTABLE(self)   ((StrBufVTable*)((FanObj*)self)->vtable)


extern Type*    StrBuf_classType;
extern VTable*  StrBuf_classVTable;


/* [sys::StrBuf] Attributes */
struct StrBuf
{
  FanObj        super;
  Char*         buffer;
  Int           capacity;
  Int           len;
};


/* [sys::StrBuf] Virtual-table */
typedef struct StrBufVTable
{
  FanObjVTable  super;
} StrBufVTable;


/* [sys::StrBuf] Methods and fields */
void            StrBuf_make_0(StrBuf* self);
void            StrBuf_make(StrBuf* self, Int capacity);
Str*            StrBuf_toStr(Obj self);
Int             StrBuf_capacity(StrBuf* self);
void            StrBuf_setCapacity(StrBuf* self, Int val);
Bool            StrBuf_isEmpty(StrBuf* self);
Int             StrBuf_size(StrBuf* self);
Int             StrBuf_get(StrBuf* self, Int index);
StrBuf*         StrBuf_set(StrBuf* self, Int index, Int ch);
StrBuf*         StrBuf_add(StrBuf* self, NullableObj x);
StrBuf*         StrBuf_addChar(StrBuf* self, Int ch);
StrBuf*         StrBuf_join_1(StrBuf* self, NullableObj x);
StrBuf*         StrBuf_join(StrBuf* self, NullableObj x, Str* sep);
StrBuf*         StrBuf_insert(StrBuf* self, Int index, NullableObj x);
StrBuf*         StrBuf_remove(StrBuf* self, Int index);
StrBuf*         StrBuf_removeRange(StrBuf* self, Range* r);
StrBuf*         StrBuf_clear(StrBuf* self);
OutStream*      StrBuf_out(StrBuf* self);


/* [sys::StrBuf] Extra methods */
StrBuf*         StrBuf_new(Int capacity);
StrBuf*         StrBuf_addSubstr(StrBuf* self, Str* str, Int start, Int end);


/* [sys::StrBuf] Type-system functions */
Type*           StrBuf_initType(void);
VTable*         StrBuf_initVTable(void);
void            StrBuf_initStatic(void);


#endif
